package vip.xiaonuo.smzq.modular.kcl.controller;

import javax.annotation.Resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import vip.xiaonuo.smzq.modular.kcl.entity.Zl;
import vip.xiaonuo.smzq.modular.kcl.service.IZlService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;


/**
 * 矿山质量
 *
 * @author eomer
 * @since 2024-02-22
 */
@Api(tags = "矿山质量")
@RestController
@RequestMapping("/kcl/zl")
@Validated
public class ZlController {

    @Resource
    private IZlService iZlService;

    /**
     * 添加矿山质量
     */
    @ApiOperation("添加矿山质量")
    @PostMapping("/add")
    public CommonResult<String> add(@RequestBody @Valid Zl zl) {
        iZlService.save(zl);
        return CommonResult.ok();
    }

    /**
     * 删除矿山质量
     */
    @ApiOperation("删除矿山质量")
    @PostMapping("/delete")
    public CommonResult<String> delete(@ApiParam(name = "pkid", value = "主键") @RequestParam String pkid) {
        iZlService.removeById(pkid);
        return CommonResult.ok();
    }

    /**
     * 编辑矿山质量
     */
    @ApiOperation("编辑矿山质量")
    @PostMapping("/edit")
    public CommonResult<String> edit(@RequestBody @Valid Zl zl) {
        iZlService.updateById(zl);
        return CommonResult.ok();
    }

    /**
     * 矿山质量分页查询
     */
    @ApiOperation("矿山质量分页查询")
    @GetMapping("/list")
    public CommonResult<List<Zl>> page() {
        return CommonResult.data(iZlService.selectList());
    }
}
